package com.dk.controller;


import com.dk.bean.Result;
import com.dk.em.ResultEnum;
import com.dk.pojo.CooperativeMerchant;
import com.dk.service.CooperativeMerchantService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 帅杰
 * @since 2021-08-13  运营商合作商家
 */
@RestController
@RequestMapping("/cooperativeMerchant")
public class CooperativeMerchantController {

    @Autowired
    private CooperativeMerchantService cooperativeMerchantService;

    @GetMapping("toSelect")
    @ApiOperation(value = "查询")
    public Result toSelect(){
       List<CooperativeMerchant> merchantList= cooperativeMerchantService.toSelect();
        return Result.buildResult(ResultEnum.SUCCESS).setData(merchantList);
    }
    @PostMapping()
    @ApiOperation(value = "新增")
    private Result toInsert(@RequestBody CooperativeMerchant merchant){
        cooperativeMerchantService.toInsert(merchant);
        return Result.buildResult(ResultEnum.SUCCESS);
    }
    @PutMapping("toUpdate")
    @ApiOperation(value = "修改")
    public Result toUpdate(@RequestBody CooperativeMerchant merchant){
        cooperativeMerchantService.toUpdate(merchant);
        return Result.buildResult(ResultEnum.SUCCESS);
    }
    @DeleteMapping("/{merchantId}")
    @ApiOperation(value = "删除")
    public Result toDetele(@PathVariable("merchantId")Long merchantId){
        cooperativeMerchantService.toDetele(merchantId);
        return Result.buildResult(ResultEnum.SUCCESS);
    }


}

